package com.linkage.jz.bankruptcy.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import static com.linkage.jz.bankruptcy.adapter.ZQPreviewModelAdapter.CATEGORY;
import static com.linkage.jz.bankruptcy.adapter.ZQPreviewModelAdapter.PIC;
import static com.linkage.jz.bankruptcy.adapter.ZQPreviewModelAdapter.TEXT;

public class ZQPreviewDetail implements Parcelable {

    private String label;
    private String content;
    private boolean required;
    private int previewType;

    ZQPreviewDetail(String categoryLabel) {
        this.label = categoryLabel;
        this.previewType = CATEGORY;
    }

    @IntDef({
//            CATEGORY,
            TEXT,
            PIC
    }) //限定为MAN,WOMEN
    @Retention(RetentionPolicy.SOURCE) //表示注解所存活的时间,在运行时,而不会存在 .class 文件中
    public @interface ZQPreviewType { //接口，定义新的注解类型
    }

    /**
     *
     * @param label 标题
     * @param content content 文字类型content 图片类型content对应picUrl
     * @param required
     * @param previewType
     */
    public ZQPreviewDetail(String label, String content, boolean required, @ZQPreviewType int previewType) {
        this.label = label;
        this.content = content;
        this.required = required;
        this.previewType = previewType;
    }

    protected ZQPreviewDetail(Parcel in) {
        label = in.readString();
        content = in.readString();
        required = in.readByte() != 0;
        previewType = in.readInt();
    }

    public static final Creator<ZQPreviewDetail> CREATOR = new Creator<ZQPreviewDetail>() {
        @Override
        public ZQPreviewDetail createFromParcel(Parcel in) {
            return new ZQPreviewDetail(in);
        }

        @Override
        public ZQPreviewDetail[] newArray(int size) {
            return new ZQPreviewDetail[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(label);
        dest.writeString(content);
        dest.writeByte((byte) (required ? 1 : 0));
        dest.writeInt(previewType);
    }

    public String getLabel() {
        return label;
    }

    public String getContent() {
        return content;
    }

    public boolean isRequired() {
        return required;
    }

    public int getPreviewType() {
        return previewType;
    }
}
